package com.dhp.bkapiinterface.Utils;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.http.HttpUtil;
import com.dhp.bkapiinterface.common.ErrorCode;
import com.dhp.bkapiinterface.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.Set;

/**
 * get请求工具类
 */
public class GetUtil {

    public static String doGet(String url , Map<String , Object> parameterMap){
        String res;
        if (!CollectionUtil.isEmpty(parameterMap)) {
            res = HttpUtil.get(url, parameterMap);
        }else {
            res = HttpUtil.get(url);
        }
        if (null == res){
            throw new BusinessException(ErrorCode.OPERATION_ERROR , "接口异常");
        }
        return res.replaceAll("\\s*|\r|\n|\t","");
    }
}
